package gdut.imis.controller;

import gdut.imis.Utils.Result;
import gdut.imis.domain.Certificates;
import gdut.imis.service.CertificatesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author JiaFu
 * @Date 2023/4/7 13:01
 */
@RestController
@RequestMapping("/certificates")
@Api(value = "证书档案接口",tags = {"证书档案接口"})
@RequiredArgsConstructor
public class CertificatesController extends BaseController {

    private final CertificatesService certificatesService;

    @ApiOperation("新增证书档案")
    @PostMapping("/addCertificates")
    @PreAuthorize("@cp.hasPermission('certificates')")
    public Result addCertificates(@RequestBody Certificates certificates){
        return certificatesService.addCertificates(certificates);
    }

    @ApiOperation("根据学生id查询学生第一次考取证书的证书档案回忆录")
    @GetMapping("/getCertificateMemoryByStuId/{studentId}")
    public Result getCertificateMemoryByStuId(@PathVariable("studentId") Long studentId){
        return certificatesService.getCertificateMemoryByStuId(studentId);
    }

}
